package cn.edu.jmu.oelp.mapper;

import cn.edu.jmu.oelp.pojo.Entity;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Repository
public interface EntityMapper {

    @Options(useGeneratedKeys =true, keyProperty = "entityId")
    @Insert("insert into entity(paragraphs_id,article_id,content,type,user_id) values(#{paragraphsId},#{articleId},#{content},#{type},#{userId})")
    public int addEntity(Entity entity);

    @Delete("delete from entity where id=#{entityId}")
    public boolean delEntity(int entityId);

    @Update("update entity set paragraphs_id = #{paragraphsId},article_id = #{articleId},content = #{content},type = #{type} where id = #{entityId}")
    public boolean updateEntity(Entity entity);

    @Select("select * from entity where id=#{entityId}")
    public Entity selEntityById(int entityId);


    /**
     * Wen
     * @param userId 传入用户id
     * @return 若返回0则说明此用户未标注，有数字则传回上层接口继续调用
     */
    int lastParagraphsId(@Param("user_id")int userId);
}
